<template>
  <div>
    <div class="seed_top_banner">
      <div class="seed_back_arrow" @click="back">
        <svg class="icon" aria-hidden="true">
          <use xlink:href="#icon-zuo"></use>
        </svg>
      </div>
      <div class="seed_page_title"><span>修改密码</span></div>
      <div class="seed_page_tool"></div>
    </div>
    <!--表单-->
    <div class="seed_my_setpwd_container">
      <div class="seed_my_setpwd_container_ch">
        <span class="seed_my_setpwd_container_tip"></span>
        <span class="seed_my_setpwd_container_name">初始密码</span>
      </div>
      <div class="seed_my_setpwd_container_ch" style="height: 4rem">
        <input type="text" class="seed_my_setpwd_container_input" v-model="param.old_pwd" placeholder="请输入初始密码"/>
      </div>
      <div class="seed_my_setpwd_container_ch">
        <span class="seed_my_setpwd_container_tip"></span>
        <span class="seed_my_setpwd_container_name">新密码</span>
      </div>
      <div class="seed_my_setpwd_container_ch" style="height: 4rem">
        <input type="text" class="seed_my_setpwd_container_input" v-model="param.new_pwd" placeholder="请输入新密码"/>
      </div>
      <div class="seed_my_setpwd_container_ch">
        <span class="seed_my_setpwd_container_tip"></span>
        <span class="seed_my_setpwd_container_name">确认密码</span>
      </div>
      <div class="seed_my_setpwd_container_ch">
        <input type="text" class="seed_my_setpwd_container_input" v-model="param.res_pwd" placeholder="请确认新密码"/>
      </div>
    </div>
    <button class="seed_my_setpwd_confirm" @click="editPwd">确认修改</button>
  </div>
</template>
<script>
export default {
  data () {
    return {
      param: {
        old_pwd: '',
        new_pwd: '',
        res_pwd: ''
      }
    }
  },
  created () {},
  methods: {
    back () {
      this.$router.push({name: 'my-setting'})
    },
    editPwd () {
      if (this.param.old_pwd === '' || this.param.new_pwd === '' || this.param.res_pwd === '') {
        this.$toast('密码不能为空')
        return false
      }
      if (this.param.new_pwd !== this.param.res_pwd) {
        this.$toast('请重新确认密码')
        return false
      }
      this.$MessageBox.confirm('确定要修改密码吗?').then(action => {
        this.$request.EditPwd(this.param).then(data => {
          this.$utils.setCookie('token', '', -1)
          this.$toast('密码已修改,请重新登录')
          this.$router.push({name: 'passport-login'})
        })
      })
    }
  }
}
</script>
